import { IPSAppDEFUIMode } from '../../app/dataentity/ipsapp-defuimode';
import { IPSDEFFormItem } from '../../control/form/ipsdefform-item';
import { IPSDEFUIMode } from './ipsdefuimode';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEFUIModeImpl extends PSModelObjectImpl implements IPSDEFUIMode, IPSAppDEFUIMode {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdefformitem: IPSDEFFormItem | null = null;

  getPSDEFFormItem(): IPSDEFFormItem | null {
    if (this.psdefformitem != null) return this.psdefformitem;
    const value = this.M.getPSDEFFormItem;
    if (value == null) {
      return null;
    }
    this.psdefformitem = this.getPSModel4('control.form.IPSDEFFormItem', value, 'getPSDEFFormItem') as IPSDEFFormItem;
    return this.psdefformitem;
  }

  get psDEFFormItem(): IPSDEFFormItem | null {
    return this.getPSDEFFormItem();
  }

  getPSDEFFormItemMust(): IPSDEFFormItem {
    const value = this.getPSDEFFormItem();
    if (value == null) {
      throw new Error('未指定属性表单项模式');
    }
    return value;
  }

  get type(): 'DEFAULT' | 'CUSTOM' | 'MOBILEDEFAULT' | 'APPDEFAULT' | 'MODE1' | 'MODE2' | 'MODE3' | 'MODE4' | 'MODE5' | 'MODE6' | 'MODE7' | 'MODE8' | 'MODE9' {
    return this.M.type;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get mobileMode(): boolean {
    return this.M.mobileMode != null ? this.M.mobileMode : false;
  }

  get cls(): string {
    return 'PSDEFUIModeImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.dataentity.IPSAppDEFUIMode' || cls == 'app.dataentity.IPSAppDataEntityObject' || cls == 'dataentity.defield.IPSDEFUIMode') return true;
    return super.instanceof(cls);
  }
}
